﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;              //命名空间
using System.Data.SqlClient;    //数据库头文件
using System.Data.Sql;         //数据库头文件
using DATA_operate_;          //自定义数据库操作类引用
using System.Web.UI.HtmlControls;




public partial class MasterPage : System.Web.UI.MasterPage
{
    DATA_operate data_operate_in_myinfo = new DATA_operate();   //创建数据库操作类对象
   


    protected void Page_Load(object sender, EventArgs e)
    {
        HttpCookie cookie = Request.Cookies["teaid"];
        string str_Tid = cookie.Value.ToString();
        string adminname = data_operate_in_myinfo.dataread("_teacher", "_Tname", "_Tid", str_Tid);
        Label1.Text = "欢迎您" + adminname +"老师";


        string backgroudtype = data_operate_in_myinfo.dataread("_teacher", "_Tbackgroud", "_Tid", str_Tid);
        
        
        /*
        //修改head标签中的title标签属性
        Page.Header.Title = "编程改变内容页标题";
        //修改head标签包含的其它标签属性，间接修改了页面背景颜色
        Style myStyle = new Style();
        myStyle.BackColor = System.Drawing.Color.Red;
        Page.Header.StyleSheet.CreateStyleRule(myStyle, null, "html");
        //添加新标签meta到head标签中
        HtmlMeta metaKeywords = new HtmlMeta();
        metaKeywords.Name = "KEYWORDS";
        metaKeywords.Content = "asp.net,c#";
        HtmlHead head = Page.Header;
        head.Controls.Add(metaKeywords);
        */
     
   // KS.Attributes.Add("background", Page.Request.ApplicationPath.ToString() + "/image/background/landingbg1.png");
        backgroudtype = backgroudtype.Replace(" ", "");
       
        Page.IsStartupScriptRegistered("i");
        switch (backgroudtype)
            {
                case "1":
                    Page.RegisterStartupScript("i", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/1.jpg'</script>");
                    break;
                case "2":
                    Page.RegisterStartupScript("i", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/2.jpg'</script>");
                    break;
                case "3":
                    Page.RegisterStartupScript("i", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/3.jpg'</script>");
                    break;
                case "4":
                    Page.RegisterStartupScript("i", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/4.jpg'</script>");
                    break;
                case "5":
                    Page.RegisterStartupScript("i", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/5.jpg'</script>");
                    break;
                case "6":
                    Page.RegisterStartupScript("i", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/6.jpg'</script>");
                    break;
                case "7":
                    Page.RegisterStartupScript("i", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/7.jpg'</script>");
                    break;
                case "8":
                    Page.RegisterStartupScript("i", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/8.jpg'</script>");
                    break;
                case "9":
                    Page.RegisterStartupScript("i", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/9.jpg'</script>");
                    break;
                default:
          
                        Page.RegisterStartupScript("i", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/9.jpg'</script>");
                    break;
             
            }



        Random ran = new Random();
        int RandKey = ran.Next(1, 24);
        string choose = "" + RandKey;
        string path = "~/image/face/" + choose + ".png";
        Image1.ImageUrl = path;
      
    }
 


    protected void buttom1(object sender, ImageClickEventArgs e)
    {
        HttpCookie cookie = Request.Cookies["teaid"];
        string str_Tid = cookie.Value.ToString();
        if (!Page.IsStartupScriptRegistered("a1"))
            Page.RegisterStartupScript("a1", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/1.jpg'</script>");
        data_operate_in_myinfo.Data_update("_teacher", "_Tbackgroud","1", "_Tid", str_Tid);
    }

    protected void buttom2(object sender, ImageClickEventArgs e)
    {
        HttpCookie cookie = Request.Cookies["teaid"];
        string str_Tid = cookie.Value.ToString();
        if (!Page.IsStartupScriptRegistered("a2"))
            Page.RegisterStartupScript("a2", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/2.jpg'</script>");
        data_operate_in_myinfo.Data_update("_teacher", "_Tbackgroud", "2", "_Tid", str_Tid);
    }

    protected void buttom3(object sender, ImageClickEventArgs e)
    {
        HttpCookie cookie = Request.Cookies["teaid"];
        string str_Tid = cookie.Value.ToString();
        if (!Page.IsStartupScriptRegistered("a3"))
            Page.RegisterStartupScript("a3", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/3.jpg'</script>");
        data_operate_in_myinfo.Data_update("_teacher", "_Tbackgroud", "3", "_Tid", str_Tid);
    }
    protected void buttom4(object sender, ImageClickEventArgs e)
    {
        HttpCookie cookie = Request.Cookies["teaid"];
        string str_Tid = cookie.Value.ToString();
        if (!Page.IsStartupScriptRegistered("a4"))
            Page.RegisterStartupScript("a4", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/4.jpg'</script>");
        data_operate_in_myinfo.Data_update("_teacher", "_Tbackgroud", "4", "_Tid", str_Tid);
    }

    protected void buttom5(object sender, ImageClickEventArgs e)
    {
        HttpCookie cookie = Request.Cookies["teaid"];
        string str_Tid = cookie.Value.ToString();
        if (!Page.IsStartupScriptRegistered("a5"))
            Page.RegisterStartupScript("a5", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/5.jpg'</script>");
        data_operate_in_myinfo.Data_update("_teacher", "_Tbackgroud", "5", "_Tid", str_Tid);
    }

    protected void buttom6(object sender, ImageClickEventArgs e)
    {
        HttpCookie cookie = Request.Cookies["teaid"];
        string str_Tid = cookie.Value.ToString();
        if (!Page.IsStartupScriptRegistered("a6"))
            Page.RegisterStartupScript("a6", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/6.jpg'</script>");
        data_operate_in_myinfo.Data_update("_teacher", "_Tbackgroud", "6", "_Tid", str_Tid);
    }

    protected void buttom7(object sender, ImageClickEventArgs e)
    {
        HttpCookie cookie = Request.Cookies["teaid"];
        string str_Tid = cookie.Value.ToString();
        if (!Page.IsStartupScriptRegistered("a7"))
            Page.RegisterStartupScript("a7", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/7.jpg'</script>");
        data_operate_in_myinfo.Data_update("_teacher", "_Tbackgroud", "7", "_Tid", str_Tid);


    }
    protected void buttom8(object sender, ImageClickEventArgs e)
    {
        HttpCookie cookie = Request.Cookies["teaid"];
        string str_Tid = cookie.Value.ToString();
        Page.IsStartupScriptRegistered("a8");
            Page.RegisterStartupScript("a8", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/8.jpg'</script>");
        data_operate_in_myinfo.Data_update("_teacher", "_Tbackgroud", "8", "_Tid", str_Tid);

    }
    protected void buttom9(object sender, ImageClickEventArgs e)
    {
        HttpCookie cookie = Request.Cookies["teaid"];
        string str_Tid = cookie.Value.ToString();
        if (!Page.IsStartupScriptRegistered("a9"))
            Page.RegisterStartupScript("a9", @"<script>window.document.body.background='http://localhost:4297/mei_design/image/background/9.jpg'</script>");
        data_operate_in_myinfo.Data_update("_teacher", "_Tbackgroud", "9", "_Tid", str_Tid);
    }

    protected void ImageButton10_Click(object sender, ImageClickEventArgs e)   //链接1   百度首页
    {
        Response.Write("<script>window.location='http://www.baidu.com'</script>");
    }
    protected void ImageButton11_Click(object sender, ImageClickEventArgs e) //链接2   有意思吧首页
    {
        Response.Write("<script>window.location='http://www.u148.net/'</script>");
    }
    protected void ImageButton12_Click(object sender, ImageClickEventArgs e) //链接2   songtaste首页
    {
        Response.Write("<script>window.location='http://www.songtaste.com/'</script>");
    }
}
